#ifndef ASYNCSERVICE_H
#define ASYNCSERVICE_H

#include "../global.h"
#include <boost/asio/io_service.hpp>
#include <boost/function.hpp>

class AsyncService : protected boost::noncopyable
{
public:
    typedef boost::asio::io_service Implement;

    typedef boost::function< void () > Task;

public:
    AsyncService();
    ~AsyncService();

    Implement &implement();

    void post(BOOST_ASIO_MOVE_ARG(Task) t);

    void dispatch(BOOST_ASIO_MOVE_ARG(Task) t);

    void run();

    void stop();

    bool stopped();

protected:
    Implement m_impl;
};

#endif // ASYNCSERVICE_H
